﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace MvcEngine.Core.Validation
{
    public class LengthFieldValidatorAdapter : DataAnnotationsModelValidator<LengthValidatorAttribute>
    {
        public LengthFieldValidatorAdapter(ModelMetadata metadata, ControllerContext context, LengthValidatorAttribute attribute)
            : base(metadata, context, attribute)
        {
            
        }

        public override IEnumerable<ModelClientValidationRule> GetClientValidationRules()
        {
            return new[] { new ModelClientValidationStringLengthRule(ErrorMessage, (int)Attribute.MinLength, (int)Attribute.MaxLength) };
        }
    }
}
